package com.ruoyi.food.serviceImpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.food.mapper.TAttachMapper;
import com.ruoyi.food.object.TAttach;
import com.ruoyi.food.service.TAttachService;

@Service
public class TAttachServiceImpl extends ServiceImpl<TAttachMapper,TAttach> implements TAttachService {

	@Autowired
	private TAttachMapper tAttachMapper;
	@Override
	public void save(List<TAttach> tAttachs) {
		// TODO Auto-generated method stub
		//this.saveBatch(tAttachs);
		tAttachMapper.insertBatchTAttach(tAttachs);
		

	}
	@Override
	public List<TAttach> findTAttachByFK(long attFkId, String attFkName) {
		// TODO Auto-generated method stub
		return tAttachMapper.selectTAttachByFK(attFkId, attFkName);
	}
	@Override
	public void deleteTAttachById(List<Long> attIds) {
		// TODO Auto-generated method stub
		tAttachMapper.deleteTAttachById(attIds);
	}
	@Override
	public void setLogo(long attId, long enterpriseId) {
		// TODO Auto-generated method stub
		List<TAttach> tAttachs=tAttachMapper.selectTAttachByFK(enterpriseId, "t_enterprise_set_logo");
		for(TAttach tAttach:tAttachs) {
			tAttachMapper.updateFkNameByAttId(tAttach.getAttId(), "t_enterprise_logo");
		}
		tAttachMapper.updateFkNameByAttId(attId, "t_enterprise_set_logo");
	}

}
